package spr.lime.hello.controller;



import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import spr.lime.hello.model.HelloTestModel;
import spr.lime.hello.service.HelloService;


@Controller
public class HelloController {
	
	
	private ApplicationContext context = new ClassPathXmlApplicationContext("/config/applicationContext.xml");
	private HelloService hService = (HelloService) context.getBean("helloService");
	//어떤식으로든 top과 left 가 정해진다
	String ttop,left;
	String getV;
	
	
	
	@RequestMapping("/hello.do")
	public ModelAndView login(HttpServletRequest request, HttpServletResponse response) {		
		//return "/hello/hello";
		//db서 불러오든 직접 쓰던
		this.ttop ="/include/header.jsp";
		this.left ="/include/left.jsp";
		this.getV = request.getParameter("cate1");
		ModelAndView mav = new ModelAndView();
		
		//mav.addObject("pageHtml", pageHtml);
		List<HelloTestModel> boardList ;
		boardList = hService.getList();
		
		mav.addObject("boardList", boardList);
		mav.addObject("ttop", ttop);
		mav.addObject("left", left);
		mav.addObject("getV", getV);
		mav.setViewName("/hello/hello");
		return mav;
	}
	
}
